﻿using FunArts.EasyDevOps.Shared.Models.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FunArts.EasyDevOps.Shared.Models.SshClient.Command
{
    /// <summary>
    /// 压缩、解压文件、目录
    /// </summary>
    public class TarCommand:ILinuxCommand
    {
        /// <summary>
        /// 命令类型
        /// </summary>
        public TarCommandTypeEnum CommandType { get; set; }
        /// <summary>
        /// 源路径
        /// </summary>
        public string Source { get; set; } 
        /// <summary>
        /// 输出文件路径
        /// </summary>
        public string OutputFile { get; set; } 


        public string BuildCommand(SystemVersionTypeEnum systemVersionType)
        {
            switch (CommandType)
            {
                case TarCommandTypeEnum.Package:
                    return $"tar -czf {OutputFile} {Source}";
                case TarCommandTypeEnum.UnPackage:
                    return $"tar -xzf {Source} -C {OutputFile}";
                default:
                    return string.Empty;
            }
        }
    }
}
